home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / PASCAL / ALLSWAGS.ZIP / SWAGG-M.ZIP / MISC.SWG / 0151_32-Bit Registers.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-05-26  |  2.4 KB  |  74 lines

  1. {
  2. >I read in the BP7 bug list that BP7 doesn't save the extended registers
  3. >EAX through to EDX during an interrupt. Has anyone got the Inline code to
  4. >do this for me? I don't know assembler, so your help would be
  5. >appreciated.
  6.  
  7. You only need to do this if your program might change them, i.e. your ISR
  8. uses longint calculations.  If that's the case, there are two approaches to
  9. saving them.
  10.  
  11. From: dmurdoch@mast.queensu.ca (Duncan Murdoch)
  12.  
  13. 1.  Faster and smaller, but uses 16 bytes of stack space:
  14. }
  15.  procedure PushEAXtoEDX;
  16.  Inline(
  17.   $66/                   {  db $66}
  18.   $50/                   {  push ax}
  19.   $66/                   {  db $66}
  20.   $53/                   {  push bx}
  21.   $66/                   {  db $66}
  22.   $51/                   {  push cx}
  23.   $66/                   {  db $66}
  24.   $52);                  {  push dx}
  25.  
  26.  procedure PopEDXtoEAX;
  27.  Inline(
  28.   $66/                   {  db $66}
  29.   $5A/                   {  pop dx}
  30.   $66/                   {  db $66}
  31.   $59/                   {  pop cx}
  32.   $66/                   {  db $66}
  33.   $5B/                   {  pop bx}
  34.   $66/                   {  db $66}
  35.   $58);                  {  pop ax}
  36.  
  37. { 2.  Slightly slower and bigger, but only uses 8 bytes of stack space: }
  38.  
  39.   procedure PushHighWordEAXtoEDX;
  40.   Inline(
  41.   $66/                   {  db $66}
  42.   $50/                   {  push ax}
  43.   $58/                   {  pop ax}
  44.   $66/                   {  db $66}
  45.   $53/                   {  push bx}
  46.   $5B/                   {  pop bx}
  47.   $66/                   {  db $66}
  48.   $51/                   {  push cx}
  49.   $59/                   {  pop cx}
  50.   $66/                   {  db $66}
  51.   $52/                   {  push dx}
  52.   $5A);                  {  pop dx}
  53.  
  54.   procedure PopHighWordEDXtoEAX;
  55.   Inline(
  56.   $52/                   {  push dx}
  57.   $66/                   {  db $66}
  58.   $5A/                   {  pop dx}
  59.   $51/                   {  push cx}
  60.   $66/                   {  db $66}
  61.   $59/                   {  pop cx}
  62.   $53/                   {  push bx}
  63.   $66/                   {  db $66}
  64.   $5B/                   {  pop bx}
  65.   $50/                   {  push ax}
  66.   $66/                   {  db $66}
  67.   $58);                  {  pop ax}
  68. {
  69. (I used David Baldwin's INLINE assembler to get the opcodes.)
  70.  
  71. These are untested.  For tested ones, look at the source to TRASHDET,
  72. included with the bug list.
  73. }
  74.